package com.service.Impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.dao.UsersDao;
import com.domain.User;
import com.domain.Users;
import com.service.UsersService;
import com.util.SqlSessionUtils;

public class UsersServiceImpl implements UsersService{
		SqlSession sqlSession = SqlSessionUtils.getSqlSession();
		UsersDao usersDao = sqlSession.getMapper(UsersDao.class);

    //查询用户
    @Override
    public List<Users> findUser() {
        return usersDao.findUser();
    }
    //查看是否查询到用户
    @Override
    public Users findUserName(String str) {
        return usersDao.findUserName(str);
    }

    //查看是否查询到用户
    @Override
    public boolean findName(String str) {
        if(usersDao.findUserName(str) == null) {
            return false;
        }
        return true;
    }
    //添加用户
    @Override
    public void addUser(User user) {
        usersDao.addUser(user);
        //提交事务
        sqlSession.commit();
    }
    //查询用户
    @Override
    public User findByName(String str) {
        return usersDao.findByName(str);
    }
    @Override
    public void updatePassword(int id, String str) {
        usersDao.updatePassword(id, str);
        //提交事务
        sqlSession.commit();
    }


}
